<h1>Listing documents</h1>

<table>
  <tr>
    <th colspan="2">Title</th>
    <th>Size</th>
    <th>Content Type</th>
    <th>Description</th>
  </tr>

<% @documents.each do |document| %>
  <tr>
    <td>
      <% if Document::IMAGE.include?(document.content_type) %>
        <%= image_tag url_for :controller => :documents, :action => :image, :id => document.id %>
      <% else %>
        <%= link_to 'Download', {:controller => :documents, :action => :item, :id => document.id} %>
      <% end %>
    </td>
    <td><%=h document.title %></td>
    <td><%=h number_to_human_size document.size %></td>
    <td><%=h document.content_type %></td>    
    <td><%=h document.description %></td>
    <td><%= link_to 'Show', document %></td>
    <td><%= link_to 'Edit', edit_document_path(document) %></td>
    <td><%= link_to 'Destroy', document, :confirm => 'Are you sure?', :method => :delete %></td>
  </tr>
<% end %>
</table>

<br />

<%= link_to 'New document', new_document_path %>